package Class_Object;

public class People {
    private String name;
    private int age;


    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return this.name;
    }


    public People(String name, int age) {
        this.name = name;
        this.age = age;
    }

}
class Test{
    public static void main(String[] args) {
        People people = new People("小白",18);
//        people.name = "小黑";name被private修饰,我们无法在不同类里面访问它
        people.setName("小黑");//我们可以通过set方法来设置这个private修饰的属性
        System.out.println(people.getName());//再调用getName这个方法来获得这个属性的值
    }
}


